package com.lx.oms.controller.service.impl;

import java.math.BigInteger;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lx.oms.common.entity.Page;
import com.lx.oms.common.entity.Query;
import com.lx.oms.common.entity.R;
import com.lx.oms.common.utils.CommonUtils;
import com.lx.oms.controller.entity.UserEntity;
import com.lx.oms.controller.manager.UserManager;
import com.lx.oms.controller.service.UserService;

/**
 * 用户表
 *
 * @author houzhong
 * @date 2018年7月10日 上午9:24:32
 */
@Service("userService")
public class UserServiceImpl implements UserService {

	@Autowired
	private UserManager userManager;

	@Override
	public Page<UserEntity> listUser(Map<String, Object> params) {
		Query query = new Query(params);
		Page<UserEntity> page = new Page<>(query);
		userManager.listUser(page, query);
		return page;
	}

	@Override
	public R saveUser(UserEntity role) {
		int count = userManager.saveUser(role);
		return CommonUtils.msg(count);
	}

	@Override
	public R getUserById(BigInteger id) {
		UserEntity tUser = userManager.getUserById(id);
		return CommonUtils.msg(tUser);
	}

	@Override
	public R updateUser(UserEntity tUser) {
		int count = userManager.updateUser(tUser);
		return CommonUtils.msg(count);
	}

	@Override
	public R batchRemove(String[] id) {
		int count = userManager.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

	@Override
	public R updateUserEnable(String[] id) {
		int count = userManager.updateUserEnable(id);
		return CommonUtils.msg(id, count);
	}

	@Override
	public R updateUserDisable(String[] id) {
		int count = userManager.updateUserDisable(id);
		return CommonUtils.msg(id, count);
	}

}
